package com.blb.goods_service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blb.goods_service.entity.Brand;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * tb_Brand表mapper接口
 */
public interface BrandMapper extends BaseMapper<Brand> {

    /**
     * 通过分类id查询品牌
     * @param cid
     * @return
     */
    @Select("SELECT b.* FROM tb_brand b\n" +
            "JOIN tb_category_brand cb\n" +
            "ON b.id = cb.brand_id\n" +
            "JOIN tb_category c\n" +
            "ON c.id = cb.category_id\n" +
            "WHERE c.id = #{cid}")
    List<Brand> selectBrandsByCategory(Integer cid);
}
